package starter.data;

import java.util.ArrayList;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class ForgotenTestCases {
	
	int startSize;

	public void runTestCases(ArrayList<String> codeInjection,
			int codeInjectionSize) {
		ArrayList<String> webElements = new ArrayList<String>();
		webElements.add("email");
		codeInjections(codeInjection, codeInjectionSize, webElements);
		codeInjectionsVariatonsSecondValue(codeInjection, codeInjectionSize, webElements);
		codeInjectionsVariatonsFirstValue(codeInjection, codeInjectionSize, webElements);
		forgotenSuccesfull(webElements);
	}
	
	private void forgotenSuccesfull(ArrayList<String> webElements) {
		WebDriver driver = new FirefoxDriver();
		driver.get("https://www.snapsation.com/login/forgot");
		WebElement email = driver.findElement(By.name(webElements.get(0)));
		email.sendKeys("damciodamcio666@gmail.com");
		email.submit();
		try {
			Thread.sleep(1800);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	private void codeInjectionsVariatonsFirstValue(
			ArrayList<String> codeInjection, int codeInjectionSize,
			ArrayList<String> webElements) {
		for(startSize = 1; startSize < codeInjectionSize; startSize++){
			WebDriver driver = new FirefoxDriver();
			driver.get("https://www.snapsation.com/login/forgot");
			WebElement email = driver.findElement(By.name(webElements.get(0)));
			email.sendKeys(codeInjection.get(startSize) + "damciodamcio666@gmail.com");
			email.submit();
			try {
				Thread.sleep(1800);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}

	private void codeInjectionsVariatonsCodeInjectionFirstValue(ArrayList<String> codeInjection,
			int codeInjectionSize, ArrayList<String> webElements) {
		for(startSize = 0; startSize < codeInjectionSize; startSize++){
			WebDriver driver = new FirefoxDriver();
			driver.get("https://www.snapsation.com/login/forgot");
			WebElement email = driver.findElement(By.name(webElements.get(0)));
			email.sendKeys(codeInjection.get(startSize));
			email.submit();
			try {
				Thread.sleep(1800);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}
	
	private void codeInjections(ArrayList<String> codeInjection,
			int codeInjectionSize, ArrayList<String> webElements) {
		for(startSize = 1; startSize < codeInjectionSize; startSize++){
			WebDriver driver = new FirefoxDriver();
			driver.get("https://www.snapsation.com/login/forgot");
			WebElement email = driver.findElement(By.name(webElements.get(0)));
			email.sendKeys(codeInjection.get(startSize));
			email.submit();
			try {
				Thread.sleep(1800);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}

	private void codeInjectionsVariatonsSecondValue(ArrayList<String> codeInjection,
			int codeInjectionSize, ArrayList<String> webElements) {
		for(startSize = 1; startSize < codeInjectionSize; startSize++){
			WebDriver driver = new FirefoxDriver();
			driver.get("https://www.snapsation.com/login/forgot");
			WebElement email = driver.findElement(By.name(webElements.get(0)));
			email.sendKeys("damciodamcio666@gmail.com" + codeInjection.get(startSize));
			email.submit();
			try {
				Thread.sleep(1800);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}
	
}
